# field_management/admin.py
from django.contrib import admin
from .models import Field

@admin.register(Field)
class FieldAdmin(admin.ModelAdmin):
    list_display = ('name', 'owner', 'area', 'location', 'updated_at')
    list_filter = ('owner', 'soil_type', 'irrigation_source')
    search_fields = ('name', 'location', 'notes', 'owner__username')
    readonly_fields = ('created_at', 'updated_at')
    fieldsets = (
        (None, {'fields': ('owner', 'name', 'area')}),
        ('详细信息', {'fields': ('location', 'latitude', 'longitude', 'soil_type', 'irrigation_source', 'notes'), 'classes': ('collapse',)}),
        ('时间戳', {'fields': ('created_at', 'updated_at'), 'classes': ('collapse',)}),
    )